// packageB/pages/jia_index/jia_index.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    appurl: app.apiurl,
    apiimg: app.apiimg,
    gglist: '',
    gglist1: '',
    gglist2: '',
    jplist: '',
    page_no: 1,
    statusHeight: '',
    autoplay: true,
    interval: 2000,
    duration: 500,
    login: false,
    list1: [
      'SKll精华', 'SKll精华', 'SKll精华'
    ],
    list2: [
      'SKll精华', 'SKll精华', 'SKll精华'
    ],
    list3: [],
    list5: [],
    luodi: false,
    tanchuang14: false,
    tanchuang24: false,
    idxttc: false,
    idxttc1: false,
    yindao: false,
    yindaonum: false,
    kh_info: false,
    tj_activity: false,
    bm_status: '0',
    baoming77: false,
    member_name: '',
    member_id: '',
    tanchuang3: false,
    yonghu: [],
    khgjs_pm_index: '0',
    saixuan: false,
    saixuan1:false,
    is_sp:'0',
    sxlist1: ['不限', '游戏等级高', '被拉黑次数少', '好评高', '获冠军多'],
    order_type: 0,
    sxlist2: ['不限', '男', '女'],
    sx_sex: 0,
    sxlist3: ['不限', '微信区', 'QQ区'],
    sx_area: 0,
    sxlist4: [{
        id: "0",
        title: "不限",
        xz_flag: false
      }, {
        id: "1",
        title: "对抗路",
        xz_flag: false
      },
      {
        id: "2",
        title: "中路",
        xz_flag: false
      },
      {
        id: "3",
        title: "发育路",
        xz_flag: false
      },
      {
        id: "4",
        title: "打野",
        xz_flag: false
      },
      {
        id: "5",
        title: "辅助",
        xz_flag: false
      }
    ],
    sx_fenlu: [],
    sx_fenlu1:false,
    sxlist5: [],
    sx_yxdj: [],
    sx_yxdj1:false,
    sx_zx: 0,
    sx_gj: 0,
    sx_tc: 0,
    sx_sc: 0,
    supei:false,
    xinrenyindao1:false,
    xinrenyindao2:false,
    xinrenyindao3:false,
    xinrenyindao4:false,
    xinrenyindao5:false,
    xinrenyindao6:false,
    xinrenyindao7:false,
    xinrenyindao8:false,
    xinrenyindao9:false,
    xinrenyindao10:false,
    xinrenyindao11:false,
    xinrenyindao12:false,
    xinrenyindao13:false,
    kftanchuang:false,
    wanshanziliao:false,
    wanshanziliao1:false,
    yindaojiesu:false,
    is_clear:0,
    xydb_pm_status:'0',
    bm_wztzs_status:'0',
    xydb_pm:'',
    bottomHeight:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      　bottomHeight : app.globalData.bottomHeight 
    })
  },
  z_open1(){
    this.setData({
      kftanchuang:true
    })
  },
  z_close() {
    this.setData({
      tanchuang3: false,
      saixuan1:false,
      kftanchuang:false
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.gaodu()
    this.z_idxgg()
    this.z_yonghu()
    this.guanggao1()
    this.z_jilu()
    this.z_kefu()
  },
  gaodu() {
    let res = wx.getSystemInfoSync();
    let statusHeight = res.statusBarHeight;
    this.setData({
      statusHeight: statusHeight
    })
  },
  z_idxgg() {
    let _this = this
    let params = {
      "token": wx.getStorageSync("user_token"),
    }
    wx.request({
      url: app.apiurl + 'api/home/index',
      method: 'POST',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
        _this.setData({
          login: true,
          idx_gg: res.data.data,
          xydb_pm_status:res.data.data.xydb_pm_status,
          bm_wztzs_status:res.data.data.bm_wztzs_status,
          xydb_pm:res.data.data.xydb_pm
          // time1:res.data.data.activity_info.diff_time
        })
        // _this.z_time()
        if (res.data.data.kh_info != '') {
          _this.setData({
            kh_info: true
          })
        }
        if (res.data.data.tj_activity != '') {
          _this.setData({
            tj_activity: true
          })
        }
        setTimeout(function(){
          _this.z_bsInfoData()
        },500)
      }
    })
  },
  z_yonghu() {
    let _this = this
    let params = {
      "token": wx.getStorageSync("user_token"),
    }
    wx.request({
      url: app.apiurl + 'api/member/myInfo',
      method: 'POST',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
        if (res.data.code == '1001') {
          let tmp_khgjs_pm = '0';
          if (res.data.data.khgjs_pm > 10) {
            tmp_khgjs_pm = '10+'
          } else {
            tmp_khgjs_pm = res.data.data.khgjs_pm
          }
          _this.setData({
            login: true,
            yonghu: res.data.data,
            khgjs_pm_index: tmp_khgjs_pm
          })
        }
      }
    })
  },
  guanggao1() {
    let _this = this
    let params = {
      "token": wx.getStorageSync("user_token"),
    }
    wx.request({
      url: app.apiurl + 'api/config/advertPage',
      method: 'POST',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
        console.log(res.data.data)
        _this.guanggao2()
        _this.guanggao3()
        _this.guanggao4()
      }
    })
  },
  guanggao2() {
    let _this = this
    let params = {
      "token": wx.getStorageSync("user_token"),
    }
    wx.request({
      url: app.apiurl + 'api/config/advert?page_id=17',
      method: 'GET',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
        _this.setData({
          gglist: res.data.data[0]
        })
      }
    })
  },
  guanggao3() {
    let _this = this
    let params = {
      "token": wx.getStorageSync("user_token"),
    }
    wx.request({
      url: app.apiurl + 'api/config/advert?page_id=21',
      method: 'GET',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
        _this.setData({
          gglist1: res.data.data[0]
        })
      }
    })
  },
  guanggao4() {
    let _this = this
    let params = {
      "token": wx.getStorageSync("user_token"),
    }
    wx.request({
      url: app.apiurl + 'api/config/advert?page_id=1',
      method: 'GET',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
        _this.setData({
          gglist2: res.data.data[0]
        })
      }
    })
  },
  z_bsInfoData() {
    let _this = this
    let params = {
      "token": wx.getStorageSync("user_token"),
    }
    wx.request({
      url: app.apiurl + 'api/home/bsInfoData',
      method: 'POST',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
        _this.setData({
          xydb_pm_status:res.data.data.xydb_pm_status,
          bm_wztzs_status:res.data.data.bm_wztzs_status,
          xydb_pm:res.data.data.xydb_pm
        })
      }
    })
  },
  z_jilu() {
    let _this = this
    let sx_sex = _this.data.sx_sex;
    if(sx_sex == 1){
      sx_sex = '男'
    } else if(sx_sex == 2){
      sx_sex = '女'
    } else {
      sx_sex = ''
    }
    let order_type = _this.data.order_type;
    let sx_area = _this.data.sx_area;
    let sx_fenlu = _this.data.sx_fenlu;
    let sx_yxdj = _this.data.sx_yxdj;
    let sx_zx = _this.data.sx_zx;
    let sx_gj = _this.data.sx_gj;
    let sx_tc = _this.data.sx_tc;
    let sx_sc = _this.data.sx_sc;
    let params = {
      "token": wx.getStorageSync("user_token"),
      "page_no":'1' ,
      "page_num":"500",
      "is_sp":_this.data.is_sp,
      "order_type": order_type,
      "sx_sex": sx_sex, 
      "sx_area": sx_area,
      "sx_fenlu": sx_fenlu.join(), 
      "sx_yxdj": sx_yxdj.join(), 
      "sx_zx": sx_zx, 
      "sx_gj": sx_gj,
      "sx_tc": sx_tc, 
      "sx_sc": sx_sc,
      "is_clear":_this.data.is_clear
    }
    wx.request({
      url: app.apiurl + 'api/home/memberShowList',
      method: 'POST',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
        if(_this.data.is_sp == '1' && res.data.code == '1001'){
          wx.showToast({
            title: '速配成功奖励' + _this.data.peizhi.config_param24 + '夺宝券',
            icon: 'none',
            duration: 2000
          })
          _this.setData({
            is_sp:0
          })
        }
        if(res.data.code == '1002'){
          wx.showToast({
            title: '金币不足请充值',
            icon: 'none',
            duration: 2000
          })
        }
        let list3 = res.data.data.list
        _this.setData({
          list3: list3
        })
      }
    })
  },
  z_kefu(){
    let _this = this
    let params = {
      "token":wx.getStorageSync("user_token"),
    }
    wx.request({
      url: app.apiurl + 'api/wztzs/tzsList',
      method: 'GET',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
         _this.setData({
           kefu:res.data.data
         })
      }
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})